import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';

// 通过Vite的import.meta.glob()方法实现自动化导入路由
const viewRouterModules = import.meta.glob('../views/**/*.vue');

// 子路由
// const routes = Object.keys(viewRouterModules).map((path)=>{
// 	const name = path.match(/\.\.\/views\/(.*)\.vue$/)[1].split('/')[1];
// 	return {
// 		path: `/${name.toLowerCase()}`,
// 		name: name,
// 		component: viewRouterModules[path]
// 	}
// })

// 路由
const routes = [
  {
    path: '/',
    name: '',
    redirect: '/index',
  },
  {
    path: '/index',
    name: 'index',
    component: () => import('@/views/index/index.vue'),
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: routes as RouteRecordRaw[],
});

export default router;
